package com.saas.demo.controller;

import com.saas.demo.model.User;
import com.saas.demo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: demo
 * @description:
 * @author: guoxh
 * @create: 2019-01-25 11:50
 **/
@RestController
@RequestMapping(value = "/user")
public class UserController {

    @Autowired
    private IUserService iUserService;

    @PostMapping("/save")
    public ResponseEntity save(@RequestBody User user) {
        User responseUser = iUserService.save(user);
        return new ResponseEntity(responseUser, HttpStatus.OK);
    }

    @GetMapping("/users")
    public ResponseEntity users() {
        List<User> userList = iUserService.getUserList();
        return new ResponseEntity(userList, HttpStatus.OK);
    }

}
